package com.jetsum.micro.service;

import com.jetsum.micro.entity.Order;
import com.jetsum.micro.mapper.OrderMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.time.LocalDateTime;

@Service
public class OrderServiceImpl implements OrderService {

    @Resource
    private OrderMapper orderMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public String save() {
        Order order = new Order();
        order.setOrderNo(System.currentTimeMillis() + "");
        order.setCreatedBy("test");
        order.setOrderType(1);
        order.setCreatedTime(LocalDateTime.now());
        orderMapper.insert(order);
        return "success";
    }
}
